<template>
	<view style="background-color: #f3f5f7;height: 100vh;">
		<view class="searchPP">
			<image @click="goBackM" style="width: 0.6rem; height: 1rem; padding: 0rem 0.5rem 0rem 0rem" src="../../style/image/cargo/leftarow.jpg"
			 alt="" />
			<view class="searchP">
				<view class="search" :style="{ width: '100%' }">
					<u-search placeholder="请输入订单号" shape="round" v-model="keyword" @search="searchOrder" :show-action="false"></u-search>
				</view>
				<!-- <view @click="celendarM" class="celendar">
                <image :style="{ width:'1.1rem',height:'1.1rem', margin:'0rem 0.5rem'}" src="../../style/image/stati/日历@3x.png" alt="">
                <view>2019.10.09</view>
                </view> -->
			</view>
		</view>

		<view>
			<view class="classesifyP">
				<view class="classesify">
					<view :class="selectIfy == 1 ? 'classesify-puc' : 'classesify-pucs'" @click="pucM">
						本人
					</view>
					<!-- <view class="classesify-pucs" @click="pucM" v-else>代理12</view> -->

					<view class="classesify-bus" @click="busM" v-if="selectIfy === 1">
						下级
					</view>
					<view class="classesify-buss" @click="busM" v-else>下级</view>
				</view>
			</view>
		</view>


		<u-calendar v-model="show" active-bg-color='#02af74' range-bg-color='#02af74' active-color='white' range-color='#02af74'
		 btn-type='success ' :mode="mode"></u-calendar>

		<view v-show="selectIfy === 1" class="my">

			<view style="background-color: white;">
				<u-dropdown>
					<u-dropdown-item v-model="value1" title="全部商户" active-color='#19be6b' height="500" :options="options1" @change="change1"></u-dropdown-item>
					<u-dropdown-item v-model="value2" title="全部设备" active-color='#02af74' height="1000" :options="options2" @change="change2"></u-dropdown-item>
					<u-dropdown-item v-model="value3" title="全部状态" active-color='#02af74' :options="options3" @change="change3"></u-dropdown-item>
				</u-dropdown>
			</view>

			<view class="totle-price">
				<view class="totle-price-text">
					<span>订单数：</span><span>{{repairLists.length}}</span><span>个</span>
				</view>

				<view @click="calendarShowM" :style="{ display:'flex', justifyContent:'center' ,alignItems:'center' ,backgroundColor:'white', borderRadius:'5px',padding:'0.3rem' }">
					<image :style="{  width:'1rem',height:'1rem' }" src="../../style/image/stati/A33.png" alt="">
						<view :style="{ fontSize:'0.6rem', padding:'0rem 0rem 0rem 0.5rem' }">{{selectTime}}</view>
				</view>
			</view>

			<view style="background-color: #f3f5f7;padding: 1rem;" class="repairListsP">

				<view class="repairLists" v-for="(item,index) in repairLists" :key="index">
					<view @click="orderDetailedM(item.id)" class="repairLists-child">

						<view class="repairLists-top">
							<view style="display: flex;align-items: center;">
								<image style="width: 1rem;;height:1rem;margin-right: 0.3rem;" src="../../style/image/order/charge.png" alt="">
									<view>
										<span style="font-size: 0.72rem;font-family: PingFang SC;
								font-weight: 300;color: #02AF74;">
											({{item.modelsName}})</span>
										<span style="font-size: 0.72rem;font-family: PingFang SC;font-weight: 300;">
											{{item.orderSn}}</span></view>
							</view>

							<view>{{orderStatusString(item.orderStatus)}}</view>
						</view>

						<view class="repairLists-head">
							<view style="
						  display: flex;
						  align-items: center;
						  justify-content: space-between;
						  margin: 0.2rem 0rem; ">
								<view style="
								font-size: 0.72rem;
								font-family: PingFang SC;
								font-weight: 300;
								color: #333333; ">
									租借商户 </view>
								<view style="
								font-size: 0.72rem;
								font-family: PingFang SC;
								font-weight: 300;
								color: #333333; ">
									{{item.outShopName}} </view>
							</view>

							<view v-if="item.orderStatus=='end'" style="
						  display: flex;
						  align-items: center;
						  justify-content: space-between;
						  margin: 0.2rem 0rem; ">
								<view style="
								font-size: 0.72rem;
								font-family: PingFang SC;
								font-weight: 300;
								color: #333333; ">
									归还商户 </view>
								<view style="
								font-size: 0.72rem;
								font-family: PingFang SC;
								font-weight: 300;
								color: #333333; ">
									{{item.inShopName}} </view>
							</view>

							<view style="
						  display: flex;
						  align-items: center;
						  justify-content: space-between;
						  margin: 0.2rem 0rem; ">
								<view style="
								font-size: 0.72rem;
								font-family: PingFang SC;
								font-weight: 300;
								color: #333333; ">
									充电宝SN码 </view>
								<view style="
								font-size: 0.72rem;
								font-family: PingFang SC;
								font-weight: 300;
								color: #333333; ">
									{{item.bankSn}} </view>
							</view>

							<view style="
						  display: flex;
						  align-items: center;
						  justify-content: space-between;
						  margin: 0.2rem 0rem; ">
								<view style="
								font-size: 0.72rem;
								font-family: PingFang SC;
								font-weight: 300;
								color: #333333; ">
									底座SN码 </view>
								<view style="
								font-size: 0.72rem;
								font-family: PingFang SC;
								font-weight: 300;
								color: #333333; ">
									{{item.outSn}} </view>
							</view>

							<view style="
						  display: flex;
						  align-items: center;
						  justify-content: space-between;
						  margin: 0.2rem 0rem; ">
								<view style="
								font-size: 0.72rem;
								font-family: PingFang SC;
								font-weight: 300;
								color: #333333; ">
									租借时间 </view>
								<view style="
								font-size: 0.72rem;
								font-family: PingFang SC;
								font-weight: 300;
								color: #333333; ">
									{{item.rentDate}} </view>
							</view>

							<view v-if="item.orderStatus=='end'" style="
						  display: flex;
						  align-items: center;
						  justify-content: space-between;
						  margin: 0.2rem 0rem; ">
								<view style="
								font-size: 0.72rem;
								font-family: PingFang SC;
								font-weight: 300;
								color: #333333; ">
									归还时间 </view>
								<view style="
								font-size: 0.72rem;
								font-family: PingFang SC;
								font-weight: 300;
								color: #333333; ">
									{{item.backDate}} </view>
							</view>

						</view>
					</view>

					<view :style="{ display: 'flex',justifyContent: 'center',padding: '0.5rem'}">
						<u-modal v-model="showModel" title="结束订单" :mask-close-able="true" @confirm="confirmModel">
							<view class="slot-content">
								<view class="" style="padding-left: 15px;">
									<view @click="endOrderShow" class="" style="display: flex;justify-content: space-between;position: relative;align-items: center;padding: 20px 0 8px 0;">
										<text>操作类型</text>
										<input type="text" v-model="endOrderDic.name" disabled="true" placeholder="请选择" style="margin-right: 30px;text-align: right;width: 65%;"/>
												<u-icon name="arrow-right" style="position: absolute;z-index:999;color: #ccc;top: 42%;right: 10px;"></u-icon>
									</view>
											<view v-if="endOrderDic.name == '指定金额'" class="" style="display: flex;padding: 8px 0;border-top: 1px solid #f3f4f7;">
												<text>指定金额</text>
												<input type="number" v-model="endOrderDic.money" placeholder="请输入金额" style="text-align: right;width: 71%;"/>
											</view>
									<view class="" style="display: flex;padding: 8px 0;border-top: 1px solid #f3f4f7;">
										<text>备注</text>
										<input type="text" v-model="endOrderDic.description" placeholder="请输入备注" style="text-align: right;width: 83%;"/>
									</view>
								</view>
							</view>
						</u-modal>
						<view v-if="item.orderStatus!='end'" class="repairBtn" @click="closeOrder(item)">结束订单</view>
					</view>
				</view>

				<!-- <u-loadmore v-show="loadmoreModal" :status="loadStatus" :load-text="loadText"/> -->
				<uni-load-more @clickLoadMore="clickLoadMore" :content-text="contentText" :status="status"></uni-load-more>
				<!-- <u-empty   style="margin-top:0rem;" v-if="repairLists.length==0" text="暂无数据" mode="data"></u-empty> -->

			</view>


			<u-popup v-model="popupShow" mode="bottom">
				<view>
					<view style="text-align: center;margin: 1rem 0rem 0rem 0rem;">请选择筛选类型:</view>
					<view class="classesifyP">
						<view class="classesify">
							<view :class="selectIfyC==1?'classesify-puc':'classesify-pucs' " @click="puckMonth">按月</view>
							<!-- <view class="classesify-pucs" @click="puckMonth" v-else>代理12</view> -->
							<view class="classesify-buss" @click="puckDay" v-if="selectIfyC == 2">按日</view>
							<view class="classesify-bus" @click="puckDay" v-else>按日</view>
						</view>
					</view>
				</view>
			</u-popup>

			<u-picker v-model="pickerShow" @confirm="pickerConfirm" mode="time"></u-picker>
			<u-select v-model="selectShow" :default-value=[10,10] mode="mutil-column" :list="list" @confirm="selectConfirm"></u-select>


		</view>

		<view v-show="selectIfy === 2" class="lower">
			<view style="background-color: white">

				<u-dropdown>
					<u-dropdown-item v-model="value4" title="排序" active-color='#02af74' :options="options4" @change="change4"></u-dropdown-item>
				</u-dropdown>

			</view>

			<view class="totle-price" style="
          font-size: 0.72rem;
          padding: 0.5rem;
          font-family: PingFang SC;
          font-weight: 300;
          color: #666666;
          display: flex;
          justify-content: center;
        ">
				下级订单数:{{getDownNumber(lowerLevelLists)}}个
			</view>

			<view style="background-color: #f3f5f7; padding: 0rem 1rem 1rem 1rem" class="repairListsP">
				<view class="repairLists" v-for="(item, index) in lowerLevelLists" :key="index">
					<view class="repairLists-child">
						<view class="repairLists-top">
							<view style="display: flex; align-items: center">
								<image style="width: 1rem;height:1rem;margin-right: 0.3rem" src="../../style/image/order/charge.png" alt="" />
								<view>
									<span style="
                      font-size: 0.72rem;
                      font-family: PingFang SC;
                      font-weight: 300;
                      color: #02af74;
                    ">{{item.userInfo.nickName}}</span>

								</view>
							</view>

							<view>{{item.orderCount}}</view>
						</view>

						<view class="repairLists-head">
							<view style="
                  display: flex;
                  align-items: center;
                  justify-content: space-between;
                  margin: 0.2rem 0rem;
                ">
								<view style="
                    font-size: 0.72rem;
                    font-family: PingFang SC;
                    font-weight: 300;
                    color: #333333;
                  ">
									充电宝数
								</view>
								<view style="
                    font-size: 0.72rem;
                    font-family: PingFang SC;
                    font-weight: 300;
                    color: #333333;
                  ">
									{{getNumber("1",item.terminalCountList)}}
								</view>
							</view>
							<view style="
                  display: flex;
                  align-items: center;
                  justify-content: space-between;
                  margin: 0.2rem 0rem;
                ">
								<view style="
                    font-size: 0.72rem;
                    font-family: PingFang SC;
                    font-weight: 300;
                    color: #333333;
                  ">
									底座数
								</view>
								<view style="
                    font-size: 0.72rem;
                    font-family: PingFang SC;
                    font-weight: 300;
                    color: #333333;
                  ">
									{{getNumber("2",item.terminalCountList)}}
								</view>
							</view>


						</view>


					</view>


				</view>
				<u-empty style="margin-top:0rem;" v-if="lowerLevelLists.length==0" text="暂无数据" mode="data"></u-empty>
			</view>
		</view>
		<u-select v-model="isEndOrder" mode="mutil-column" value-name="code" label-name="name" :list="endOrderList" @confirm="endOrderChange"></u-select>
	</view>
</template>

<script lang='ts'>
	import {
		Component,
		Prop,
		Vue,
		Watch,
		Emit
	} from "vue-property-decorator";

	import {
		userOrderListRenting
	} from "../../utils/uniApi";
	import {
		subsetProxyOrderList
	} from "../../utils/uniApi";
	import {
		findShopBox
	} from "../../utils/uniApi";
	import {
		findTerminalBox
	} from "../../utils/uniApi";
	import {
		endOrder,getOrderEnumBox
	} from "../../utils/uniApi";

	import uniLoadMore from '../loadMore/uni-load-more.vue'

	@Component({
		//   @Component  是一个装修器   不可以在下面写语句
		name: "test",
		components: {
			'uniLoadMore': uniLoadMore
		}
	})
	export default class extends Vue {
		@Prop({
			type: String, // 父组件传递给子组件的数据类型
			required: false, // 是否必填
			default: " ", // 默认值， 如果传入的是 Object，则要 default: ()=>({}) 参数为函数
		})
		msg!: string;

		public selectIfy: any = 1; //本人和下级的tab 切换
		public pageN: any = 1; //分页的页数
		//加载参数
		// public loadStatus = "nomore";
		// public loadText = {
		//   loadmore: "轻轻上拉",
		//   loading: "努力加载中",
		//   nomore: "暂无更多数据",
		// };
		// public loadmoreModal = true;
		public status = 'more'

		public contentText = {
			contentdown: '下拉或点击查看更多',
			contentrefresh: '加载中',
			contentnomore: '没有更多'
		}
		public continueTypes = true;

		public keyword = ""; //搜索关键字
		public xshopId: any = ''; //下拉框选择的商户id
		public xposTypeId: any = ''; //下拉框选择的设备id
		public xorderType: any = ''; //下拉框选择的订单状态
		public xsort: any = 'orderCountAsc'; //下拉框选择的排序方式
		public lowerLevelLists = []; //下级代理订单
		public repairLists = []; //本人 订单


		public popupShow = false //show日历选择控件
		public pickerShow = false //日历按日选择控件
		public selectShow = false //日历按月选择控件
		public selectTime = "请选择日期";
		
		public selectIfyC: any = 0; //选择日  月的切换tab
		public selectDate: any = {
			type: '',
			value: ''
		}; //日期选择  type类型day:按日 month:按月  value选择的日期值

		public list = [
			[{
					value: '1',
					label: '2010'
				},
				{
					value: '2',
					label: '2011'
				},
				{
					value: '3',
					label: '2012'
				},
				{
					value: '4',
					label: '2013'
				},
				{
					value: '5',
					label: '2014'
				},
				{
					value: '6',
					label: '2015'
				},
				{
					value: '7',
					label: '2016'
				},
				{
					value: '8',
					label: '2017'
				},
				{
					value: '9',
					label: '2018'
				},
				{
					value: '10',
					label: '2019'
				},
				{
					value: '11',
					label: '2020'
				},
				{
					value: '12',
					label: '2021'
				},
			],
			[{
					value: '13',
					label: '1'
				},
				{
					value: '14',
					label: '2'
				},
				{
					value: '15',
					label: '3'
				},
				{
					value: '16',
					label: '4'
				},
				{
					value: '17',
					label: '5'
				},
				{
					value: '18',
					label: '6'
				},
				{
					value: '19',
					label: '7'
				},
				{
					value: '20',
					label: '8'
				},
				{
					value: '21',
					label: '9'
				},
				{
					value: '22',
					label: '10'
				},
				{
					value: '23',
					label: '11'
				},
				{
					value: '24',
					label: '12'
				},
			],
		];

		public value1 = 0; //全部商户排序默认值
		public value2 = 0; //全部设备排序默认值
		public value3 = 0; //全部状态排序默认值
		public value4 = 0; //排序方式
		public options1: Array < any > = [{
			label: '全部商户',
			value: 0
		}];
		public options2: Array < any > = [{
			label: '全部设备',
			value: 0
		}];

		public options3 = [{
				label: "全部状态",
				value: 0,
			},
			{
				label: "租借中",
				value: 1,
			},
			{
				label: "已完成",
				value: 2,
			},
			{
				label: "超时借出",
				value: 3,
			},
		];
		public options4 = [{
				label: "综合",
				value: 0,
			},
			{
				label: "订单数由低到高",
				value: 1,
			},
			{
				label: "订单数由高到低",
				value: 2,
			},
		];

		public show = false;
		public showModel = false;
		public isEndOrder: any = false;//选择结束订单的问题
		public endOrderDic: any={name:'',code:'',orderId:'',orderSn:'',money:'',description:''};//结束订单 选中问题dic
		public endOrderList: any=[];//结束订单 问题list

		created() {}

		mounted() {
			//  console.log('父组件传递的参数:',this.$parent)   //暂时不考虑

		}

		onHide() {
			uni.hideLoading();
		}
		onBackPress() {
			uni.hideLoading();
			uni.setStorage({
				key: "allOrderTab",
				data: 1,
				success: function() {},
			});
		}

		//下拉刷新
		onPullDownRefresh() {
			setTimeout(function() {
				uni.redirectTo({
					url: "../../pages/order/allOrder",
				});
				uni.stopPullDownRefresh();
			}, 1000);
		}
		//上拉加载更多
		onReachBottom() {
			if (!this.continueTypes) {
				return
			}
			this.pageN = this.pageN + 1;
			this.orderListData(this.xshopId, this.xposTypeId, this.xorderType, this.pageN, this.selectDate, this.keyword);
		}
		clickLoadMore() {
			this.onReachBottom()
		}

		onShow() {
			this.selectDate.type = 'day';

			const Dates = new Date();
			const year: number = Dates.getFullYear();
			const month: any = (Dates.getMonth() + 1) < 10 ? '0' + (Dates.getMonth() + 1) : (Dates.getMonth() + 1);
			const day: any = Dates.getDate() < 10 ? '0' + Dates.getDate() : Dates.getDate();
			this.selectDate.value = year + '-' + month + '-' + day;
			console.log('输出当前时间：' + this.selectDate.value)
			this.selectTime = this.selectDate.value;
			this.pageN = 1;

			var current = uni.getStorageSync("allOrderTab");
			if (current == 2) {
				this.busM()
			} else {

				this.orderListData(this.xshopId, this.xposTypeId, this.xorderType, this.pageN, this.selectDate, this.keyword);
				this.findShopBox();
				this.findTerminalBox();
				this.getOrderEnumBox()
			}
		}

		//搜索框
		searchOrder(value: any) {
			this.keyword = value;
			this.pageN = 1;
			this.orderListData(this.xshopId, this.xposTypeId, this.xorderType, this.pageN, this.selectDate, this.keyword);
		}
		//   ++++++++    日期选择器   start
		calendarShowM() {
			// this.show=true
			this.popupShow = true;
		}
		puckDay() {
			//方法中获取this
			this.selectIfyC = 2;

			this.popupShow = false
			this.pickerShow = true

			setTimeout(() => {

				this.selectIfyC = 0;
			}, 1000)
		}
		puckMonth() {
			this.selectIfyC = 1;

			this.popupShow = false
			this.selectShow = true

			setTimeout(() => {

				this.selectIfyC = 0;
			}, 1000)


		}
		//按日选择  确认按钮
		pickerConfirm(data: any) {
			console.log('按日起', data)
			this.selectDate.type = 'day'
			this.selectDate.value = data.year + '-' + data.month + '-' + data.day;
			this.selectTime = this.selectDate.value;
			this.pageN = 1;
			this.orderListData(this.xshopId, this.xposTypeId, this.xorderType, this.pageN, this.selectDate, this.keyword);
		}
		//按月选择  确认按钮
		selectConfirm(data: any) {
			console.log('按月起', data)
			let str = (data[0] as any).label + '-' + (data[1] as any).label
			this.selectDate.value = str
			this.selectDate.type = 'month'
			this.selectTime = this.selectDate.value;
			this.pageN = 1;
			this.orderListData(this.xshopId, this.xposTypeId, this.xorderType, this.pageN, this.selectDate, this.keyword);
		}
		//   ++++++++    日期选择器   end


		//订单状态转换
		orderStatusString(status: string) {
			if (status == "timeout") {
				return '超时'
			} else if (status == "end") {
				return '已完成'
			} else if (status == "ing") {
				return '租赁中'
			} else {
				return ''
			}
		}
		//计算充电宝或者底座的数量
		getNumber(type: any, list: any) {
			if (list.length <= 0) {
				return 0;
			} else {
				for (let item of list) {
					if (item.type == '0' && type == '1') {
						return item.terminalCount
					} else if (item.type == '1' && type == '2') {
						return item.terminalCount
					}
				}
				return 0;
			}
		}
		//计算下级订单的数量
		getDownNumber(list:any){
			var number = 0
			list.filter((item: any, index: any) => {
			  	number = number + item.orderCount
			})
			return number;
		}
		//全部商户下拉框
		change1(value: any) {
			if (value == 0) {
				this.xshopId = ''
			} else {
				this.xshopId = value
			}
			this.pageN = 1;
			this.orderListData(this.xshopId, this.xposTypeId, this.xorderType, this.pageN, this.selectDate, this.keyword);

		}
		//全部设备下拉框
		change2(value: any) {
			if (value == 0) {
				this.xposTypeId = '';
			} else {
				this.xposTypeId = value;
			}
			this.pageN = 1;
			this.orderListData(this.xshopId, this.xposTypeId, this.xorderType, this.pageN, this.selectDate, this.keyword);

		}
		//全部状态下拉框
		change3(value: any) {
			if (value == 0) {
				this.xorderType = ''
			} else if (value == 1) {
				this.xorderType = 'ing'
			} else if (value == 2) {
				this.xorderType = 'end'
			} else if (value == 3) {
				this.xorderType = 'timeout'
			} else {
				this.xorderType = ''
			}
			this.pageN = 1;
			this.orderListData(this.xshopId, this.xposTypeId, this.xorderType, this.pageN, this.selectDate, this.keyword);
		}
		//排序下拉框
		change4(value: any) {
			if (value == 0) {
				this.xsort = 'orderCountAsc'
			} else if (value == 1) {
				this.xsort = 'orderCountDesc'
			} else if (value == 2) {
				this.xsort = 'orderCountAsc'
			} else {
				this.xsort = 'orderCountAsc'
			}
			this.subsetProxyOrderList(this.xsort, this.selectDate);
		}

		orderDetailedM(id: any) {
			uni.navigateTo({
				url: '../order/orderDetaileding?orderId=' + id
			});

		}
		//结束订单下拉框数据
		getOrderEnumBox(){
			  let params = {
			    userId:uni.getStorageSync("userId") == ""? "": parseInt(uni.getStorageSync("userId")),
			  };
			  getOrderEnumBox(params).then((res: any) => {
			      if(res.data.code==200){
					  this.endOrderList.push(res.data.data)
			      }else{
			      
			      }
			  });
		}
		//手动取消结束订单
		closeOrder(item: any) {
			this.showModel = true
			this.endOrderDic.orderId = item.id
			this.endOrderDic.orderSn = item.orderSn
		}
		//结束订单问题 选择
		endOrderShow(){
			  this.isEndOrder = !this.isEndOrder
		}
		//结束订单问题 选择 确认按钮
		endOrderChange(data:any) {
			this.isEndOrder = !this.isEndOrder
			this.endOrderDic.code = data[0].value
			this.endOrderDic.name = data[0].label
		}
		confirmModel(){
			if(this.endOrderDic.name==''){
					  uni.showToast({
						title: '请选择结束订单类型',
						icon: 'none',
						duration: 2000
					  });
					  return
			}
			if(this.endOrderDic.name=='指定金额' && this.endOrderDic.money == ''){
					  uni.showToast({
						title: '请填写指定金额',
						icon: 'none',
						duration: 2000
					  });
					  return
			}
			  uni.showLoading({
			  	title: '加载中'
			  });
			  let params = {
			  	orderSn:this.endOrderDic.orderSn,//订单号
				endOrderStatus:this.endOrderDic.code,//结束订单类型
				endOrderMoney:this.endOrderDic.money,//指定扣除金额
				description:this.endOrderDic.description,//备注
			  };
			  endOrder(params).then((res: any) => {
				  uni.hideLoading();
				  // console.log('手动取消订单：'+JSON.stringify(res))
			      if(res.data.code==200){
					uni.showToast({
						title: '手动取消订单成功',
						icon: 'none',
						duration: 2000
					});
					this.orderListData(this.xshopId, this.xposTypeId, this.xorderType, this.pageN, this.selectDate, this.keyword); //手动取消订单成功后刷新页面
			      }else{
					  uni.showToast({
						title: res.data.message,
						icon: 'none',
						duration: 2000
					  });
			      }
			  
			  });
		}
		//设备下拉选择框
		findTerminalBox() {
			let params = {
				userId: uni.getStorageSync("userId") == "" ? "" : parseInt(uni.getStorageSync("userId")),
			};
			findTerminalBox(params).then((res: any) => {
				if (res.data.code == 200) {
					if (res.data.data.length > 0) {
						for (var i = 0; i < res.data.data.length; i++) {
							let item = res.data.data[i];
							let shopItem = {
								label: item.sn,
								value: item.id
							}
							this.options2.push(shopItem);
						}
					}
				} else {

				}
			});
		}
		//商户下拉选择框
		findShopBox() {
			let params = {
				userId: uni.getStorageSync("userId") == "" ? "" : parseInt(uni.getStorageSync("userId")),
			};
			findShopBox(params).then((res: any) => {
				if (res.data.code == 200) {
					if (res.data.data.length > 0) {
						for (var i = 0; i < res.data.data.length; i++) {
							let item = res.data.data[i];
							let shopItem = {
								label: item.shopName,
								value: item.id
							}
							this.options1.push(shopItem);
						}
					}
				} else {

				}
			});
		}
		//下级代理订单
		subsetProxyOrderList(sort: string, date: any) {
			uni.showLoading({
				title: '加载中'
			});
			let params = {
				dateType: date.type, //查询条件-查询时间类型（month:月  day:日）
				queryDate: date.value, //2020-11-04       2020-11
				sortord: sort, //查询条件-排序类型（orderCountDesc 订单数量倒序，orderCountAsc 订单数量正序）
				userId: uni.getStorageSync("userId") == "" ? "" : parseInt(uni.getStorageSync("userId")),
			};
			subsetProxyOrderList(params).then((res: any) => {
				if (res.data.code == 200) {
					this.lowerLevelLists = res.data.data

					uni.hideLoading();
				} else {
					uni.hideLoading();
					uni.showToast({
						title: '数据加载失败',
						icon: 'none',
						duration: 2000
					});
				}
			});

		}

		//拉取网络数据
		orderListData(shopId: any, posTypeId: any, status: any, pageNo: any, date: any, key: any) {
			uni.showLoading({
				title: '加载中'
			});
			let params = {
				keyWord: key, //搜索关键字
				dateType: date.type, //查询条件-查询时间类型（month:月  day:日）
				queryDate: date.value, //2020-11-04       2020-11
				orderStatus: status, //查询条件 - 订单状态 timeout：超时  end：完结   ing：租赁中
				pageNo: pageNo,
				pageSize: 10,
				posTypeId: posTypeId == "" ? "" : parseInt(posTypeId), //机型id
				shopId: shopId == "" ? "" : parseInt(shopId), //商户id
				userId: uni.getStorageSync("userId") == "" ? "" : parseInt(uni.getStorageSync("userId")),
			};
			userOrderListRenting(params).then((res: any) => {
				// console.log('++++++++++++++++++++全部订单中   本人' + JSON.stringify(res.data) )
				if (res.data.code == 200) {
					// if(this.repairLists.length>0){//搜索  删除已有数据  有分页在考虑
					//  this.repairLists = [];
					// }
					// this.repairLists = res.data.data

					// uni.hideLoading();

					var boolee = res.data.hasNext == false && this.continueTypes == false;
					if (res.data.hasNext == true) {
						this.status = "more";
					} else {
						this.status = "noMore";
					}
					console.log(res.data.hasNext, this.continueTypes, boolee);
					if (res.data.isFirst || !boolee) {

						if (res.data.hasNext == false) {
							this.continueTypes = false;
						}

						if (this.repairLists.length > 0 && this.pageN == 1) { //搜索  删除已有数据
							this.repairLists = [];
						}
						this.repairLists = this.repairLists.concat(res.data.data)
						// this.repairLists = res.data.data
						uni.hideLoading();
					}

				} else {
					uni.hideLoading();
					uni.showToast({
						title: '数据加载失败',
						icon: 'none',
						duration: 2000
					});
				}
			});
		}

		busM() {
			//方法中获取this
			this.subsetProxyOrderList(this.xsort, this.selectDate);
			this.selectIfy = 2;

			uni.setStorage({
				key: "allOrderTab",
				data: this.selectIfy,
				success: function() {},
			});
		}
		pucM() {
			this.pageN = 1;
			this.orderListData(this.xshopId, this.xposTypeId, this.xorderType, this.pageN, this.selectDate, this.keyword);
			this.selectIfy = 1;

			uni.setStorage({
				key: "allOrderTab",
				data: this.selectIfy,
				success: function() {},
			});
		}

		goBackM() {
			uni.navigateBack({
				delta: 1,
			});
		}



	}
</script>

<style lang="scss" scoped>
	.searchPP {
		background-color: white;
		padding: 0.5rem;

		display: flex;
		align-items: center;
		border-bottom: 1px solid #e8e8e8;
	}

	.searchP {
		background-color: white;
		display: flex;
		width: 100%;
		justify-content: space-between;
	}


	.classesifyP {
		text-align: center;
		display: flex;
		justify-content: center;
		padding: 0.6rem;
		background-color: white;
	}

	.classesify {
		width: 4rem;
		height: 1.5rem;
		border: 1px solid #02af74;
		display: flex;
		align-items: center;
		border-radius: 5px;
		/* //   background-color: red; */
	}

	.classesify-puc {
		width: 50%;
		font-size: 0.6rem;
		border-bottom-left-radius: 5px;
		border-top-left-radius: 5px;
		height: 100%;
		line-height: 100%;
		display: flex;
		align-items: center;
		justify-content: center;
		background-color: #02af74;
	}

	.classesify-pucs {
		width: 50%;
		font-size: 0.6rem;
		border-bottom-left-radius: 5px;
		border-top-left-radius: 5px;
		height: 100%;
		line-height: 100%;
		display: flex;
		align-items: center;
		justify-content: center;
		background-color: white;
	}

	.classesify-bus {
		width: 50%;
		font-size: 0.6rem;
	}

	.classesify-buss {
		width: 50%;
		font-size: 0.6rem;
		border-bottom-right-radius: 5px;
		border-top-right-radius: 5px;
		height: 100%;
		line-height: 100%;
		display: flex;
		align-items: center;
		justify-content: center;
		background-color: #02af74;
	}

	.totle-price {
		display: flex;
		justify-content: space-between;
		align-items: center;
		background-color: #f3f5f7;
		padding: 0.2rem 0.5rem;
	}

	.totle-price-text {

		font-size: 0.73rem;
		font-family: PingFang SC;
		font-weight: 400;
		color: #000000;
	}

	.totle-price-text span {

		font-size: 0.73rem;
		font-family: PingFang SC;
		font-weight: 300;
		color: #000000;
	}


	.repairLists {

		background-color: white;
		margin-bottom: 1rem;
		border-radius: 0.2rem;
		/* padding: 1rem; */
		/* margin: 1rem; */

	}

	.repairLists-top {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 0.5rem 0.5rem;
		border-bottom: 1px solid #e8e8e8;

	}

	.slot-content {
		font-size: 28rpx;
		color: $u-content-color;
		padding-left: 30rpx;
	}

	.repairLists-child {

		border-bottom: 1px solid #E5E5E5;
	}

	.repairLists-head {
		padding: 1rem;
	}

	.repairBtn {
		width: 4.5rem;
		height: 1.5rem;
		background: #FFFFFF;
		border: 1px solid #02AF74;
		border-radius: 0.3rem;
		font-size: 0.78rem;
		font-family: PingFang SC;
		font-weight: 300;
		color: #02B074;
		text-align: center;
		align-items: center;
		line-height: 1.5rem;

	}

	.classesifyP {
		text-align: center;
		display: flex;
		justify-content: center;

		padding: 1rem 1rem 3rem 1rem;
	}

	.classesify {
		width: 6rem;
		height: 1.8rem;
		border: 1px solid #02af74;

		display: flex;
		align-items: center;
		border-radius: 10px;
		/* //   background-color: red; */
	}

	.classesify-puc {
		width: 50%;
		font-size: 0.6rem;
		border-bottom-left-radius: 8px;
		border-top-left-radius: 8px;
		height: 100%;
		line-height: 100%;
		display: flex;
		align-items: center;
		justify-content: center;
		background-color: #02af74;
	}

	.classesify-pucs {
		width: 50%;
		font-size: 0.6rem;
		border-bottom-left-radius: 8px;
		border-top-left-radius: 8px;
		height: 100%;
		line-height: 100%;
		display: flex;
		align-items: center;
		justify-content: center;
		background-color: white;
	}

	.classesify-bus {
		width: 50%;
		font-size: 0.6rem;
	}

	.classesify-buss {
		width: 50%;
		font-size: 0.6rem;
		border-bottom-right-radius: 8px;
		border-top-right-radius: 8px;
		height: 100%;
		line-height: 100%;
		display: flex;
		align-items: center;
		justify-content: center;
		background-color: #02af74;
	}
</style>
